home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Games Extra 1996 September
/
Amiga Games Extra CD-ROM 9-1996.iso
/
userbox
/
publicdomain
/
aplayer
/
files
/
arexx.lha
/
ToIFF.aplay
< prev
next >
Wrap
Text File
|
1994-09-30
|
3KB
|
105 lines
/* This script will convert all files in a directory to IFF-8SVX files */
OPTIONS RESULTS
PARSE ARG dir
IF dir="" THEN DO
SAY "Usage: rx ToIFF.aplay <directory>"
SAY
SAY "This script will convert all your files specified with"
SAY "the <directory> parameter to IFF-8SVX files."
SAY "It can only handle files up to 64Kb."
EXIT
END
/* Add the functions of the 'rexxsupport.library' */
IF ADDLIB('rexxsupport.library',0,-30,0) = 0 THEN DO
IF SHOW('L','rexxsupport.library') = 0 THEN DO
SAY "Couldn't open rexxsupport.library"
EXIT 10
END
END
/* Read the directory into a string */
dirlist=SHOWDIR(dir,'F',';')||';'
IF RIGHT(dir,1)~=':' & RIGHT(dir,1)~='/' THEN
dir=dir||'/'
/* Begin to convert the files */
IF dirlist~=';' THEN DO
DO UNTIL dirlist=''
filename=dir||LEFT(dirlist,INDEX(dirlist,';')-1)
SAY "Computing "||filename
/* Test file for a IFF-File */
IF OPEN(rdfile,filename,'R') THEN DO
test=READCH(rdfile,4)
IF test~="FORM" THEN DO
filelen=SEEK(rdfile,0,'E')
IF filelen<65535 THEN DO
IF OPEN(wrfile,filename||'.temp','W') THEN DO
WRITECH(wrfile,"FORM")
temp=D2X(filelen+40)
temp=INSERT("",temp,0,8-LENGTH(temp),'0')
WRITECH(wrfile,X2C(temp))
WRITECH(wrfile,"8SVXVHDR")
WRITECH(wrfile,X2C('00000014'))
hexlen=D2X(filelen)
hexlen=INSERT("",hexlen,0,8-LENGTH(hexlen),'0')
WRITECH(wrfile,X2C(hexlen))
WRITECH(wrfile,X2C('00000000'))
WRITECH(wrfile,X2C('00000020'))
WRITECH(wrfile,X2C('40BE'))
WRITECH(wrfile,X2C('0100'))
WRITECH(wrfile,X2C('00010000'))
WRITECH(wrfile,"BODY")
WRITECH(wrfile,X2C(hexlen))
/* Copy the file */
mem=ALLOCMEM(filelen)
IF mem~='0'x THEN DO
CALL SEEK(rdfile,0,'B')
CALL EXPORT(mem,READCH(rdfile,filelen),filelen)
WRITECH(wrfile,IMPORT(mem,filelen))
FREEMEM(mem,filelen)
CLOSE(rdfile)
CLOSE(wrfile)
CALL DELETE(filename)
CALL RENAME(filename||'.temp',filename)
END
ELSE DO
SAY "^^^^^^Out of memory^^^^^^"
CLOSE(wrfile)
CLOSE(rdfile)
CALL DELETE(filename||'.temp')
END
END
ELSE DO
CLOSE(rdfile)
SAY "^^^^^^Couldn't open temp file^^^^^^"
END
END
ELSE DO
CLOSE(rdfile)
SAY "^^^^^^File too big^^^^^^"
END
END
ELSE DO
CLOSE(rdfile)
SAY "^^^^^^File already an IFF file^^^^^^"
END
END
ELSE DO
SAY "^^^^^^Couldn't open file^^^^^^"
END
dirlist=DELSTR(dirlist,1,INDEX(dirlist,';'))
END
END